<template>
	<view>
		<u-swiper :list="info.image" previousMargin="30" nextMargin="30" circular :autoplay="false" radius="5"
			bgColor="#ffffff"></u-swiper>
		<view class="msg">
			<view class="prod-msg">
				<view class="msg-price">
				<!-- 	<text class="price-symbol">￥</text>
					<text class="price-nums-big">{{info.money}}</text> -->
					<!-- <text class="price-nums-small">{{numberSmall(info.money)}}</text> -->
				</view>
				<!-- <view class="msg-payed">{{info.sales}}人付款</view> -->
			</view>
			<view class="msg-title">{{info.title}}</view>
		</view>
		<view class="prod-params">
			<view class="prod-params-title">----规格参数----</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left">商品编号</text>
				<text class="prod-params-item-right">{{info.on}}</text>
			</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left">商品分类</text>
				<text class="prod-params-item-right">{{info.cate_title}}</text>
			</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left">商品品牌</text>
				<text class="prod-params-item-right">{{info.brand_title}}</text>
			</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left">商品规格</text>
				<text class="prod-params-item-right">{{info.sku_title}}</text>
			</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left">适用车型</text>
				<text class="prod-params-item-right">{{info.car_title}}</text>
			</view>
			<view class="prod-params-item">
				<text class="prod-params-item-left"  style="color: blue;">商品编号</text>
				<view class="prod-params-item-right"  style="color: blue;">
					{{info.order_on}}
					<view style="float: right;"  @click="copyText(info.order_on)">
						<img src="/static/fuzhi1.png" alt="" style="width: 20px; height: 20px;"/>
					</view>
				</view>
			</view>
			
		</view>
		<view class="prod-params" style="padding: 30;">
			<view class="prod-params-title">----商品详情----</view>
			<view class="prod-content">
				<view v-html="info.content"></view>
			</view>
		</view>
		<view class="order-fixed-bot">
			<view class="stash-auth" @tap="toStashAuth"> {{is_fool == 1 ? '购买报备' : '识别认证'}}</view>
		</view>
	</view>
</template>

<script>
	import { baseUrl } from '../../utils/config'
	export default {
		data() {
			return {
				id: '',
				info: {},
				from: '',
				is_fool : 1,
			}
		},
		onLoad(query) {
			if (query.id) {
				this.id = query.id
				this.stashQrcode(query.id)
			} else {
				this.from = 'qrcode'
				const q = decodeURIComponent(query.q)
				const _id = q.split('goods_id=')[1].split('&')[0]
				this.id = _id
				this.stashQrcode(_id)
			}

		},
		methods: {
			 copyText(text) {
			  uni.setClipboardData({
			    data: text,
			    success: function () {
			      console.log('复制成功');
			      // 可以添加用户友好的提示，例如使用uni.showToast提示复制成功
			      uni.showToast({
			        title: '复制成功',
			        icon: 'success',
			        duration: 2000
			      });
			    },
			    fail: function () {
			      console.log('复制失败');
			      // 可以添加错误处理或用户友好的提示
			    }
			  });
			},
			async stashQrcode(id) {
				const dd = {
					id: id
				}
				const {
					code,
					data,
					msg
				} = await this.request('goods/index', dd, 'POST')
				if (code == 1) {
					this.info = data.info
					this.is_fool = data.is_fool
				}
			},
			toStashAuth() {
				uni.request({
					url: baseUrl + 'user/index',
					method: 'POST',
					data: {},
					header: {
						'token': uni.getStorageSync('usertoken'),
					},
					success: res => {
						if (res.data.code == 244) {
							uni.showToast({
								icon: 'none',
								title: '请先登录'
							})
							if (this.from == 'qrcode') {
								uni.setStorageSync('scangoodid', this.id)
								uni.setStorageSync('mode', 'scango')
							}

							setTimeout(() => {
								uni.reLaunch({
									url: `/pages/accountLogin/accountLogin`
								})
							}, 1500)
						}
						if(res.data.code==1){
							
							if(this.is_fool==1){
								// uni.navigateTo({
								// 	url: `/pages/face-id/faceida?id=${this.id}`
								// })
								this.finals();
							}else{
								uni.navigateTo({
									url: `/pages/face-id/faceid?id=${this.id}`
								})
							}
							
							
						}
					},
				})
				
			},
			async finals() {
				
				await this.request('goods/identify', {
					id: this.id,
					face_imgs: '',
					longitude: '125.324669',
					latitude: '43.886868',
				}, 'POST').then(res => {
					if (res.code == 1) {
						uni.navigateTo({
							url: `/pages/authStatus/authStatus?status=1`
						})
					}
					if (res.code == 0) {
						uni.navigateTo({
							url: `/pages/authStatus/authStatus?status=0`
						})
					}
					if(res.code == 2){
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f7f7f7;
	}

	.msg {
		width: 750rpx;
		box-sizing: border-box;
		padding: 20rpx;
		background: #fff;
		margin-bottom: 20rpx;
	}

	.prod-msg {
		display: flex;
		height: 60rpx;
		align-items: center;
		justify-content: space-between;
	}

	.prod-params {
		padding: 30rpx 50rpx;
		background: #fff;
		margin-bottom: 20rpx;

	}

	.prod-params-title {
		font-size: 32rpx;
		text-align: center;
		color: #999;
		font-weight: 600;

	}

	.prod-params-item {
		display: flex;
		justify-content: space-between;
	}

	.prod-params-item-left {
		font-size: 28rpx;
		color: #333;
	}

	.prod-params-item-right {
		font-size: 28rpx;
		color: #666;
	}

	.msg-payed {
		color: #999;
		font-size: 24rpx;
	}

	.msg-title {
		font-size: 32rpx;
		color: #333;
		font-weight: 600;
	}

	.price-symbol {
		font-size: 26rpx;
		color: #FF0100;
	}

	.price-nums-big {
		font-size: 32rpx;
		color: #FF0100;
	}


	.price-nums-small {
		font-size: 24rpx;
		color: #FF0100;
	}

	.order-fixed-bot {
		width: 750rpx;
		padding-top: 20rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 3rpx 7rpx 0rpx rgba(0, 0, 0, 0.35);
		position: fixed;
		bottom: 0;
		left: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		padding-bottom: constant(safe-area-inset-bottom);
		/* 兼容 iOS < 11.2 */
		padding-bottom: env(safe-area-inset-bottom);
		/* 兼容 iOS >= 11.2 */
	}

	.stash-auth {
		width: 560rpx;
		height: 68rpx;
		background: #2e8bf0;
		text-align: center;
		line-height: 68rpx;
		border-radius: 34rpx;
		color: #fff;
	}
</style>